var http = require("http");
var url = require("url");
module.exports = {
	prefix: "/proxy",
	get: {
		"/": function() {
			var self = this;
			var query = self.request.query;
			var proxy_url = query.url;
			if (proxy_url) {
				// var urlInfo = url.parse(proxy_url);
				http.get(proxy_url, function(res) {
					var result = [];
					var result_len = 0;
					res.on("data", function(data) {
						result.push(data);
						result_len += data.length;
					}).on("end", function() {
						result = Buffer.concat(result, result_len);
						self.response._headers = res.headers;
						self.body = result;
					}).on("error", function() {
						self.body = "";
					});
				});
			} else {
				self.body = "";
			}
		}
	}
};